#*******************************************************
# Sistemas Operativos - Trabajo Practico 01
#
#			45310 - Bergez, Pablo
# 			45060 - Fragulia, Mariano
#			45108 - Wachnitz, German
#
#*******************************************************

#*********************
#Definicion de macros
#*********************

CC = gcc
CFLAGS = -Wall -o

COBJS = client_backend.o client_session_layer.o errlib.o frontend.o getop.o
SOBJS = server_backend.o server_session_layer.o server_transport_layer.o errlib.o


#*****************************
#Genera todos los ejecutables
#*****************************

all:			pipes socks msg shm


#*************************************************************
#Genera la aplicacion cliente servidor utilizando named pipes
#*************************************************************

pipes:			pipes_client pipes_server

pipes_client:		client.c $(COBJS) named_pipes.o
			$(CC) $(CFLAGS) $@ $?

pipes_server:		server.c $(SOBJS) named_pipes.o
			$(CC) $(CFLAGS) $@ $?


#*********************************************************
#Genera la aplicacion cliente servidor utilizando sockets
#*********************************************************

socks:			socks_client socks_server

socks_client:		client.c $(COBJS) sckts.o
			$(CC) $(CFLAGS) $@ $?

socks_server:		server.c $(SOBJS) sckts.o
			$(CC) $(CFLAGS) $@ $?


#*****************************************************************
#Genera la aplicacion cliente servidor utilizando message passing
#*****************************************************************

msg:			msg_client msg_server

msg_client:		client.c $(COBJS) msg_passing.o
			$(CC) $(CFLAGS) $@ $?

msg_server:		server.c $(SOBJS) msg_passing.o
			$(CC) $(CFLAGS) $@ $?


#***************************************************************
#Genera la aplicacion cliente servidor utilizando shared memory
#***************************************************************

shm:			shm_client shm_server

shm_client:		client.c $(COBJS) share_mem.o
			$(CC) $(CFLAGS) $@ $?

shm_server:		server.c $(SOBJS) share_mem.o
			$(CC) $(CFLAGS) $@ $?


#***************************************
#Archivos comunes a todas las versiones
#***************************************

errlib.o:			errlib.c
				$(CC) $(CFLAGS:-o=-c) $?
	
frontend.o:			frontend.c
				$(CC) $(CFLAGS:-o=-c) $?

getop.o:			getop.c
				$(CC) $(CFLAGS:-o=-c) $?

client_session_layer.o:		client_session_layer.c
				$(CC) $(CFLAGS:-o=-c) $?

server_session_layer.o:		server_session_layer.c
				$(CC) $(CFLAGS:-o=-c) $?

server_transport_layer.o:	server_transport_layer.c
				$(CC) $(CFLAGS:-o=-c) $?

client_backend.o:		client_backend.c
				$(CC) $(CFLAGS:-o=-c) $?

server_backend.o:		server_backend.c
				$(CC) $(CFLAGS:-o=-c) $?

free:				free_keys.c
				$(CC) $(CFLAGS) $@ $?


#******************************
#Distintas capas de transporte
#******************************

named_pipes.o:		named_pipes.c
			$(CC) $(CFLAGS:-o=-c) $?

sckts.o:		sckts.c
			$(CC) $(CFLAGS:-o=-c) $?

msg_passing.o:		msg_passing.c
			$(CC) $(CFLAGS:-o=-c) $?

share_mem.o:		share_mem.c
			$(CC) $(CFLAGS:-o=-c) $?


#********************************
#Rutinas de limpieza de archivos
#********************************

clean:
			rm *.o	
			rm *_client;
			rm *_server;

oclean:		
			rm *.o


